var function_id;
var fs;
function a_click(dom){
			     var modalLocation = $(dom).attr('data-reveal-id');
			     $('#'+modalLocation).reveal($(dom).data());
			     var url = $(dom).attr("path");
			     function_id = $(dom).attr("data-id");
			     $.ajax({
			    	url:url,
			    	type:'get',
			    	dataType:'json',
			    	data:{ticket:ticket,function_id:function_id,userid:user_id},
			    	success:function(data){
			    		var obj={};
			    		obj.title=data.content.message.title;
			    		obj.content = createContent(data.content.message.method,data.content.message);
			    		obj.method = data.content.message.method;
			    		$('#'+modalLocation).office_modal(obj);
			    	}
			     });
			     
			     $('a.close-reveal-modal').bind('click',function(){
					 $('a.back-reveal-modal').hide(0);
					 $('div.content').empty();
					 $('h3.reveal-modal-header').empty();
				 });
			     
			     //绑定评分星星点击切换状态事件
			     $('.reveal-modal-footer ul li:not(".fabulous")').unbind().click(function(){
			    	  var _this = $(this);
			    	  var doms = $('.reveal-modal-footer ul li:not(".fabulous")');
			    	  if(_this.hasClass("spanActive")){
			    		  var index ="";
			    		  $.each(doms,function(i,rec){
			    			  if(rec==_this[0]){
			    				 index = i;
			    				 fs=i-1;
			    				 $(rec).removeClass("spanActive");
			    			  }
			    			  if(i>index && index!=""){
			    				 $(rec).removeClass("spanActive");
			    			  }
			    		  });
			    	  }else{
			    		  $.each(doms,function(i,rec){
			    			  $(rec).addClass("spanActive");
			    			  fs=i;
			    			  if(rec==_this[0]){
			    				  return false;
			    			  }
			    		  });
			    	  }
			     });
			     //绑定点赞点击事件
			     $('.reveal-modal-footer ul li.dz').click(function(){
			    	  var _this = $(this);
			    	  _this.children("a").children("span").toggleClass("spanfabulous");
			    	  $.ajaxSettings.async=false;
			    		$.getJSON('/WDDXSERVER/bsdt/functionDz.action?userid='+user_id+'&ticket='+ticket,
			    			  {
			    				function_id:function_id
			    			  },
			    			  function(data){
			    			  });
			     });

			     //绑定提交事件
			     $('.reveal-modal-footer ul li.submit').click(function(){
			    		$.ajaxSettings.async=false;
			    		$.getJSON('/WDDXSERVER/bsdt/functionPf.action?userid='+user_id+'&ticket='+ticket,
			    			  {
			    				function_id:function_id,
			    		 		fs:fs
			    			  },
			    			  function(data){
			    			  });
			     });
			     
	   }
 function createContent(func,data){
	 return window["create"+func](data);  //灏嗗瓧绗︿覆褰撴垚鍑芥暟鎵ц
 }

 //一卡通
 function createYKT(data){
	 var html = '<div class="labels_show">'
		 +'<p>'+"一卡通余额"+data.items[0].BALANCE+"元"+'</p>'
		 +'<input type="text" class="starttime">至<input type="text" class="endtime"><button type="button" class="search_mxcx">明细查询</button>'
		 +'</div>'
		 +'<div class="content_info ">'
		 +'<table class="ykt_xfjl">'
		 +'</table>'
		 +'<div class="pagechange"><ul><li>'
		 	+'<li class="nextpage"><a href="javascript:;">下一页></a></li>'
		 	+'<li class="index"><a href="javascript:;">首页</a></li>'
			+'<li class="previouspage"><a href="javascript:;"><上一页</a></li>'
	 		+'</ul></div>'
	 	 +'</div>';
   return html;
 }

 //图书借阅
 function createlibrary(data){
	 var html ='<table class="office_library_table">'
		 		    +'<tr>'
		 		      +'<th>'+"图书名称"+'</th>'
		 		      +'<th>'+"图书编号"+'</th>'
		 		      +'<th>'+"借书时间"+'</th>'
		 		      +'<th>'+"还书时间"+'</th>'
		 		    +'</tr>';
	 if(!(data.items==0||data.items==null)){
		 $.each(data.items,function(i,rec){
			  html +='<tr>'
			            +'<td>'+rec["title"]+'</td>'
	 		            +'<td>'+rec["book_barcode"]+'</td>'
	 		            +'<td>'+rec["date_due"]+'</td>'
	 		            +'<td>'+rec["date_checkout"]+'</td>'
	 		          +'</tr>';
		 });
	 }
	html += '</table>';	 
	return html;
 }
//通讯录
 function createOffPhone(data){
	 var html = '<div class="office_phone_bm">'
	               +'<ul>';
	 var pid = [];
	 if(!(data.bmlist==0||data.bmlist==null)){
		 $.each(data.bmlist,function(i,rec){ 
			 pid.push(rec["txl_id"]);
			 if(i == 0){
				 html += '<li class="active">'+'<a href="javascript:;" path="txl'+rec["txl_id"]+'" class="'+rec["txl_id"]+'">'+rec["txl_name"]+'</a>'+'</li>';
			 }else{
				 html += '<li>'+'<a href="javascript:;" path="txl'+rec["txl_id"]+'" class="'+rec["txl_id"]+'">'+rec["txl_name"]+'</a>'+'</li>';
			 }
		 });
	 }
	 html+='<div class="clear"></div></ul>'
//		 +'<input type="text" class="searchText"><span class="search">'+"查询"+'</span>'
		 +'</div>';
//	 var html1 ="";
	 var num = 1;
	 var list=[];
	 $.each(pid,function(i,r){
		 var pids = [];
		 var divclass="";
		 list=[];
		 if(i==0){
			  divclass="office_phone_block";
		 }else{
			  divclass="office_phone_none";
		 }
		 html+='<div class="'+divclass+' pr2e pl2e pb1e" id="txl'+r+'" class="pl2e pr2e">';
		 pids.push(r);
		 callbackbm(pids,num);
		 $.each(list,function(i,r){
			   html+=r.html+'</div>'+'</div>';
			 });
		 html+='</div>';
	 });
	 function callbackbm(arr,num){
		 var pid1=[];
		 if(num==1){ //第一次循环  标题
			 $.each(data.items,function(i,rec){
				 var obj={};
				 if($.inArray(rec["txl_pid"], arr)>=0){
					if($.inArray(rec["txl_pid"],pid1)<0){
						 pid1.push(rec["txl_id"]);
						 obj.html='<div class="txltitle">'
						                  +'<div class="title">'
              						         +'<a>'
              						            + rec["txl_name"]  
   								             +'</a>' 
              						      +'</div>'
								       + '<div>';
						 obj.id=rec["txl_id"];
						 list.push(obj);
				 }
				 }
			 });
		 }else{//二次以上循环  正文
			 $.each(data.items,function(i,rec){
				 if($.inArray(rec["txl_pid"], arr)>=0){
					if($.inArray(rec["txl_pid"],pid1)<0){
						 pid1.push(rec["txl_id"]);
						 $.each(list,function(index,r){
							 if(rec["txl_pid"]==r.id){
								list[index].html+=    '<span>'
									                     +'<a>'
                									        + rec["txl_name"]
								                         +'</a>'
								                         +'<a href="javascript:;">'
								                            + rec["txl_zjhm"]
								                         +'</a>'
										              +'</span>';
							 }
						 });
					 }
				 }
			 });
		 }
		 if(pid1.length==0){
			 return false;//当没有子节点的时候跳出递归
		 }else{
			 ++num;
			 callbackbm(pid1);
		 }
	 }
	
	 return html/*+html1*/;
 }
 
 //教室查询
 function createclassRoom(data){
	 var html = '<div class="office_select xq">'
         +'<p>'+"选择校区"+'</p>'
     +'<select>';
	 if(!(data.items==0||data.items==null)){
		$.each(data.items,function(i,r){
			html += '<option value="'+r["XQDM"]+'">'+r["XQMC"]+'</option>';
			});
	 }
		html += '</select></div>';
	var html1 ='<div class="office_select classjc">'
	        +'<p>'+"选择上课节次"+'</p>'
	        +'<select>'
	            +'<option>'+1+'</option>'
	            +'<option>'+2+'</option>'
	            +'<option>'+3+'</option>'
	            +'<option>'+4+'</option>'
	            +'<option>'+5+'</option>'
	            +'<option>'+6+'</option>'
	            +'<option>'+7+'</option>'
	            +'<option>'+8+'</option>'
	            +'<option>'+9+'</option>'
	            +'<option>'+10+'</option>'
	            +'<option>'+11+'</option>'
	            +'<option>'+12+'</option>'
	        +'</select>'
	    +'</div>';
	var htmlbtn = '<div class="office_select office_btn" style="text-align:center;"><a href="javascript:;">查询</a></div>';
	var html2 = '<div  class="office_select jxl"><p>选择教学楼</p><select>';
	var _xq=data.items[0].XQDM;
	$.ajaxSettings.async = false;
	$.getJSON("/WDDXSERVER/bsdt/jscxlh.action?userid="+user_id+"&ticket="+ticket, 
		{
		xq: _xq,
		function_id:function_id
		 },
		function(data) { 
			 if(!(data["content"].message.items==0||data["content"].message.items==null)){
				$.each(data["content"].message.items,function(i,r){
					html2+='<option>'+r["LH"]+'</option>';
				}); 
			 }
 });
html2+='</select></div>';
html += html2+html1+htmlbtn;
return html;
 }

 //班车查询
 function createOffBus(data){
	 var html="";
	 if(data.content[0].article_clob){
		 html=data.content[0].article_clob;
	 }else{
		 html="there has no data";
	 }
	 return html;
 }
//成绩查询
 function createOffScore(data){
	 var html = '<div class="office_cjcx"><select id="xq">';
	 var html2="";
	 var _rm_xq = data.items[0].rm_xq;
	 if(!(data.items==0||data.items==null)){
		 $.each(data.items,function(i,r){
		 	 html+='<option value="'+r.rm_xq+'">'+r.xnxq+'</option>';
		 });
	 }
	 html+= '</select><table><tr>'
		        +'<th>'+"课程名称"+'</th>'
		        +'<th>'+"学分"+'</th>'
		        +'<th>'+"课程性质"+'</th>'
		        +'<th>'+"成绩"+'</th>'
		     +'</tr>';
	 $.ajaxSettings.async = false;
	 $.getJSON("/WDDXSERVER/home/getCJForPc.action?userid="+user_id+"&ticket="+ticket, 
	 		{ rm_xq: _rm_xq },
	 		function(data) { 
	 			 if(!(data[0].content.message.items==0||data[0].content.message.items==null)){
			 		$.each(data[0].content.message.items,function(i,r){
					 html2 += '<tr>' 
							  +'<td>'+r.class_name+'</td>'
					          +'<td>'+r.class_credit+'</td>'
					          +'<td>'+r.class_type+'</td>'
					          +'<td>'+r.class_score+'</td>'
			               +'</tr>';
					 }); 
	 			 }
	 		});
//	 html += ;
	 html=html+html2+'</table></div>';
	 return html;
 }
//学校新闻
 function createOffnews(data){
	 var html = '<div class="office_news">'
		            +'<ul>';
	 if(!data.items){
		 return null;
	 }
	 if(!(data.items==0||data.items==null)){
		 $.each(data.items,function(i,r){
			 if(i==0){
				 html += '<a class="a_active" href="javascript:;"><li class="'+r["CATEGORY_ID"]+'">'+r["CATEGORY_NAME"]+'</li></a>';
			 }else{
				 html += '<a href="javascript:;"><li class="'+r["CATEGORY_ID"]+'">'+r["CATEGORY_NAME"]+'</li></a>';
			 }
		 });
	 }
	 var html1= '<div class="clear"></div></ul></div><div class="office_news_list"><ul>';
	 var _lm=data.items[0].CATEGORY_NAME;
	 var _lmbh=data.items[0].CATEGORY_ID;
	 $.ajaxSettings.async = false;
	 $.getJSON('/WDDXSERVER/bsdt/xwlb.action?userid='+user_id+'&ticket='+ticket+'&pagesize=5&pagenow=1',
		 {cc:_lm,
		  lmbh:_lmbh,
		  function_id:function_id
		 },
		 function(data){
			 if(!(data["content"].message.items==0||data["content"].message.items==null)){
				$.each(data["content"].message.items,function(i,r){
					html1 += '<li class="'+r["ARTICLE_ID"]+'">'
						       +'<div>'
//						       +'<a href="javascript:;" class="img">'+'<img src="'+r["ARTICLE_FACE"]+'"/>'+'</a>'
						          +'<a href="javascript:;" class="title">'+r["ARTICLE_TITLE"]+'</a>'+'<span>'+r["ARTICLE_DATE"]+'</span>'
						          +'<div class="clear"></div>'
						       +'</div>'
						    +'</li>';
				});
			 }
				html1 += '</ul></div>';
		 });
	 var html2='<div class="pagechange"><ul>'
		 +'<li class="nextpage"><a>下一页></a></li>'
		 +'<li class="index"><a>首页</a></li>'
		 +'<li class="previouspage"><a><上一页</a></li>'
		 +'</ul></div>';
	 html+=html1+html2;
	return html;
 }
 
 //跳蚤市场
 function createTZSC(data){
 		 var html='<div class="office_market">'
 			 +'<ul>'
 			 +'<li class="a_active"><a href="javascript:;" class="mdx1">买东西</a></li>'
 			 +'<li><a href="javascript:;" class="mdx2">卖东西</a></li>';
 		 html+='</ul></div>';
 		 html+='<div class="office_lists"><div class="office_market_list"><div class="office_market_search">'
 			 +'<a href="javascript:;" class="wdspsc"><img src="img/scdbb.png" /><p>收藏的宝贝</p></a>'
 			 +'<button class="Dzsplb">搜索</button><input type="text" class="spmcSs"></div>'
 			 +'<div class="office_market_zs_img"><img src="img/fksg_03.png" /></div>'
 			 +'<div class="office_market_function"><ul>';
 		 if(!(data.items==0||data.items==null)){
	 		 $.each(data.items,function(i,r){
	 			 html+='<li class="'+r["flbh"]+'"><a href="javascript:;"><img src="'+r["flfm"]+'" /><span>'+r["flmc"]+'</span></a></li>';
	 		 });
 		 }
 		 html+='</ul></div></div></div>';
 		return html;
 }
 
//绑定事件函数
 function bindYKT(){
	 var mydate = new Date();
	   var yy = "" + mydate.getFullYear();
	   var mm =mydate.getMonth()+1;
	   var mm1=mydate.getMonth();
	   var dd ="" + mydate.getDate();
	   var _jssj='';
	   var _kssj='';
	   if(mm<10){
		   _kssj=yy+'0'+mm1+dd;
		   _jssj=yy+'0'+mm+dd;
	   }else{
		   _kssj=yy+mm1+dd;
		   _jssj=yy+mm+dd;
	   }
	 yktList(_kssj,_jssj,1);
	 yktTablePage(_kssj,_jssj);
	 $(".starttime").datepicker({dateFormat: "yymmdd"});
	 $(".endtime").datepicker({dateFormat: "yymmdd"});
	 $('.search_mxcx').click(function(){
		 var _kssj1=$(".starttime").val();
		 var _jssj1=$(".endtime").val(); 
		 yktList(_kssj1,_jssj1,1);
		 yktTablePage(_kssj1,_jssj1);
	 });
 }

 //一卡通消费记录表
 function yktList(_kssj,_jssj,pageNum){
	  var html='<tr><th>'+"时间"+'</th>'
//	      +'<th>'+"地点"+'</th>'
	      +'<th>'+"金额"+'</th>'
	      +'<th>'+"余额"+'</th>'
		  +'</tr>';
	 $.ajax({
		 type:'POST',
		 async:false,
		 url:'/WDDXSERVER/bsdt/ykt_xfjl.action?function_id='+function_id+'&userid='+user_id+'&ticket='+ticket+'&pageSize=5'+'&pageNum='+pageNum+'&kssj='+_kssj+'&jssj='+_jssj,
		 success:function(data){
			 if(!(data["content"].message.items==0||data["content"].message.items==null)){
				 $.each(data["content"].message.items,function(i,r){
					 html+='<tr>'
							+'<td>'+r["JNDATETIME"]+'</td>'
	//						+'<td>'+r["CONSUME_AMOUNT"]+'</td>'
							+'<td>'+r["TRANAMT"]+'</td>'
							+'<td>'+r["CARD_BALANCE"]+'</td>'
							+'</tr>';
				 });
			 }
			$('.ykt_xfjl').empty().append(html);
			 
		 }
	 });
 }
 
 function yktTablePage(_kssj,_jssj){
	 var pageNum=1;
	 $('.pagechange ul li').unbind('click').click(function(){
		 var className=$(this).attr("class");
			 if(className=='nextpage'){
				 pageNum+=1;
				 yktList(_kssj,_jssj,pageNum);
			 }else if(className=='previouspage'){
				 pageNum-=1;
				 if(pagenow==0){pagenow=1;}
				 yktList(_kssj,_jssj,pageNum);
			 }else{
				 pageNum=1;
				 yktList(_kssj,_jssj,pageNum);
			 }
	 });
 }
 //缁戝畾鍥句功棣嗕簨浠�
 function bindlibrary(){}
 //绑定通讯录事件
 function bindOffPhone(){
	 $('div.content .office_phone_bm ul li a').click(function(e){
		 var _domId = $(this).attr("path");
//		 var a = $('#'+_domId);
		 $(this).parent().siblings().removeClass("active");
		 $(this).parent().addClass("active");
		 $('#'+_domId).siblings().not(".office_phone_bm").removeClass("office_phone_block").addClass("office_phone_none");
		 $('#'+_domId).removeClass("office_phone_none").addClass("office_phone_block");
	 });

	 $('.search').click(function(){
		 var pid=$('.office_phone_bm ul li.active').children('a').attr('class');
		 var doms = $('div.office_phone_block').children().clone(true);
	    	$('div.office_phone_block').children().remove();
	    	$('input.searchText').hide(0);
	    	$('span.search').hide(0);
	    	$('a.back-reveal-modal').show(0);
	    	$('a.back-reveal-modal').unbind('click').click(function(){
	    		$(this).hide(0);
	    		$('input.searchText').show(0);
		    	$('span.search').show(0);
	    		$('div.searchList').remove();
	    		$('div.office_phone_block').append(doms);
	    	});
		 SsPhone(pid); 
	 });
 }
 function SsPhone(pid){
	 var cxtj=$('.searchText').val();
	 var html='';
	 $.ajaxSettings.async = false;
		$.getJSON("/WDDXSERVER/bsdt/txlss.action?userid="+user_id+"&ticket="+ticket, 
		 		{ pid: pid,
				  function_id:function_id,
				  cxtj:cxtj
				 },
		 		function(data) { 
					 if(!(data.content.message==0||data.content.message==null)){
				 		$.each(data.content.message,function(i,r){
				 			html='<div class="searchList">'
			                  +'<div class="title">'
						         +'<a>'
						            + r["txl_name"]  
						         +'</a>' 
						      +'</div>'
						      +'<span>'
			                     +'<a>'
							        + r["txl_name"]
		                         +'</a>'
		                         +'<a href="javascript:;">'
		                            + r["txl_zjhm"]
		                         +'</a>'
				              +'</span>';
					       + '<div>';
						 });  
					 }
		});
		$('.content div.office_phone_block').empty().append(html);
 }
//教室查询绑定事件
 function bindclassRoom(){
	 $(".xq select").change(function(e){
			var _xq=$(this).val();
			var html2 = '<p>选择教学楼</p><select>';
			$.ajaxSettings.async = false;
			$.getJSON("/WDDXSERVER/bsdt/jscxlh.action?userid="+user_id+"&ticket="+ticket, 
			 		{ xq: _xq,
					  function_id:function_id
					},
			 		function(data) { 
						 if(!(data.content.message.items==0||data.content.message.items==null)){
					 		$.each(data.content.message.items,function(i,r){
					 			html2+='<option>'+r["LH"]+'</option>';
							 }); 
						 }
			});
			html2+='</select>';
			$('.jxl').empty().append(html2);
		 });
	 
	 $('div.office_btn a').click(function(e){
		 	var _xq=$('.xq select').val();
			var _lh=$('.jxl select').val();
			var _djj=$('.classjc select').val();
	    	var doms = $('.content').children().clone(true);
	    	$('.content').children().remove();
	    	$('a.back-reveal-modal').show(0);
	    	$('a.back-reveal-modal').unbind('click').click(function(){
	    		$(this).hide(0);
	    		$('div.cxjg').remove();
	    		$('.content').append(doms);
	    	});
	    	 var htmls = '<div class="cxjg">'
	               +'<table>'
	                  +'<tr>'
	                     +'<th>'+"教学楼"+'</th>'
	                     +'<th>'+"教室名称"+'</th>'
	                     +'<th>'+"座位数"+'</th>'
	                     +'<th>'+"教室信息"+'</th>'
	                  +'</tr>';
	    	 var htmle = '';
			 $.ajaxSettings.async = false;
				$.getJSON('/WDDXSERVER/bsdt/jscxlb.action?userid='+user_id+'&ticket='+ticket, 
			 		{ xq:_xq,
			 		 lh:_lh,
			 		 djj:_djj,
			 		function_id:function_id
			 		 },
			 		function(data) { 
			 			if(!(data["content"].message.items==0||data["content"].message.items==null)){
				 			$.each(data["content"].message.items,function(i,r){
				 			 htmle += '<tr>' 
								  +'<td>'+r["LH"]+'</td>'
						          +'<td>'+r["JSMC"]+'</td>'
						          +'<td>'+r["ZWS"]+'</td>'
						          +'<td>'+r["JSLB"]+'</td>'
				               +'</tr>';
							});
			 			}
			 	});
			 
			 htmls+=htmle+'</table></div>';
	        $('.content').append(htmls);
	    });
			
 }
 //鐝溅鏌ヨ缁戝畾浜嬩欢
 function bindOffBus(){}
 //成绩查询绑定事件
 function bindOffScore(){
	 $("#xq").change(function(){
		var _rm_xq=$(this).val();
		var html='';
		var html1= '<tr>'
			        +'<th>'+"课程名称"+'</th>'
			        +'<th>'+"学分"+'</th>'
			        +'<th>'+"课程性质"+'</th>'
			        +'<th>'+"成绩"+'</th>'
			     +'</tr>';
		var html2='';
		$.ajaxSettings.async = false;
		$.getJSON("/WDDXSERVER/home/getCJForPc.action?userid="+user_id+"&ticket="+ticket, 
	 		{ rm_xq: _rm_xq },
	 		function(data) { 
	 			if(!(data[0].content.message.items==0||data[0].content.message.items==null)){
			 		$.each(data[0].content.message.items,function(i,r){
					 html2 += '<tr>' 
							  +'<td>'+r.class_name+'</td>'
					          +'<td>'+r.class_credit+'</td>'
					          +'<td>'+r.class_type+'</td>'
					          +'<td>'+r.class_score+'</td>'
			               +'</tr>';
					 });
	 			}
	 	});
		 html=html1+html2;
		 $('.office_cjcx table').empty().append(html);
	 });
	
 }
//学校新闻绑定事件
 function bindOffnews(){
	 $('div.content .office_news ul a li').click(function(e){
		 var _lmbh = $(this).attr("class");
		 var _cc=$(this).text();
		 $(this).parent().siblings().removeClass("a_active");
		 $(this).parent().addClass("a_active");
		 var html1= '<ul>';
//		 var _xwbh=ARTICLE_ID
		 $.ajaxSettings.async = false;
		 $.getJSON('/WDDXSERVER/bsdt/xwlb.action?userid='+user_id+'&ticket='+ticket+'&pagesize=5&pagenow=1',
			 {cc:_cc,
			 lmbh:_lmbh,
			 function_id:function_id
			 },
			 function(data){
				 if(!(data["content"].message.items==0||data["content"].message.items==null)){
						$.each(data["content"].message.items,function(i,r){
							html1 += '<li  class="'+r["ARTICLE_ID"]+'">'
								       +'<div>'
	//							       +'<a href="javascript:;" class="img">'+'<img src="'+r["ARTICLE_FACE"]+'"/>'+'</a>'
								          +'<a href="javascript:;" class="title">'+r["ARTICLE_TITLE"]+'</a>'+'<span>'+r["ARTICLE_DATE"]+'</span>'
								          +'<div class="clear"></div>'
								       +'</div>'
								    +'</li>';
						});
				 }
					html1 += '</ul>';
			 });
		 $('.office_news_list').empty().append(html1);
		 changeArticle();
	 });
	 changeArticle();
	 var pagenow=1;
	 $('.pagechange ul li').unbind('click').click(function(){
		 var className=$(this).attr("class");
			 if(className=='nextpage'){
				 pagenow+=1;
				 changeNewList(pagenow);
			 }else if(className=='previouspage'){
				 pagenow-=1;
				 if(pagenow==0){pagenow=1;}
				 changeNewList(pagenow);
			 }else{
				 pagenow=1;
				 changeNewList(pagenow);
			 }
	 });
	 
	
		
 }
 
 //学习新闻列表切换
 function changeNewList(pagenow){
	 var _lmbh = $('.office_news ul a li').attr("class");
	 var _cc=$('.office_news ul a li').text();
		 var html1= '<ul>';
		 $.ajaxSettings.async = false;
		 $.getJSON('/WDDXSERVER/bsdt/xwlb.action?userid='+user_id+'&ticket='+ticket+'&pagesize=5&pagenow='+pagenow,
			 {cc:_cc,
			 lmbh:_lmbh,
			 function_id:function_id
			 },
			 function(data){
				 if(!(data["content"].message.items==0||data["content"].message.items==null)){
						$.each(data["content"].message.items,function(i,r){
							html1 += '<li  class="'+r["ARTICLE_ID"]+'">'
								       +'<div>'
	//							       +'<a href="javascript:;" class="img">'+'<img src="'+r["ARTICLE_FACE"]+'"/>'+'</a>'
								          +'<a href="javascript:;" class="title">'+r["ARTICLE_TITLE"]+'</a>'+'<span>'+r["ARTICLE_DATE"]+'</span>'
								          +'<div class="clear"></div>'
								       +'</div>'
								    +'</li>';
						});
				 }
					html1 += '</ul>';
					$('.office_news_list').empty().append(html1);
		 });
		 changeArticle();

 }
 
 //进入学校新闻内容

 function changeArticle(){
	 $('div.content .office_news_list ul li a').click(function(){
			var _xwbh=$(this).parent().parent().attr("class");
			var _cc=$(this).text();
			var doms = $('.content').children().clone(true);
	    	$('.content').children().remove();
	    	$('a.back-reveal-modal').show(0);
	    	$('a.back-reveal-modal').unbind('click').click(function(){
	    		$(this).hide(0);
	    		$('div.office_list_article').remove();
	    		$('.content').append(doms);
	    	});
			var html='';
			 $.ajaxSettings.async = false;
			 $.getJSON('/WDDXSERVER/bsdt/xwnr.action?userid='+user_id+'&ticket='+ticket,
					 {
				 		xwbh:_xwbh,
				 		cc:_cc,
				 		function_id:function_id
					 },
			 		function(data){
						 if(!(data["content"].message.items==0||data["content"].message.items==null)){
							$.each(data["content"].message.items,function(i,r){
								html='<div class="office_list_article">'
									+'<h5>'+r["ARTICLE_TITLE"]+'</h5><span>'+r["ARTICLE_DATE"]+'</span>'
									+'<h4>'+r["ARTICLE_TITLE"]+'</h4>'
									+'<div class="list_article">'+r["ARTICLE_CLOB"]+'</div></div>';
							});
						 }
			 		});
			 $('.content').append(html);
		});
 }
 
//跳蚤市场应用
 function bindTZSC(){
 	 onSallsp();              //卖东西
 	 tzscSclb();             //商品收藏列表
 	 tzscLb();              //商品列表
 	 tzscDzsplb();   //搜索
  }
 
  //买卖列表标题(卖东西)
  function onSallsp(){
 	 var sun=0;
 	 sun++;
 	 var _mmlx=2;
 	 var dom='';
 		$('.mdx2').click(function(){
 			 dom=$('.office_market_list').clone(true);
 			 $(this).parent().siblings().removeClass("a_active");
 			 $(this).parent().addClass("a_active");
 	    	$('.office_market_list').remove();
 	    	$('.mdx1').unbind('click').click(function(){
 	    		 $(this).parent().siblings().removeClass("a_active");
 	    		 $(this).parent().addClass("a_active");
 	    		$('div.office_market_list_sall').remove();
 	    		$('div.pagechange').remove();
 	    		$('div.office_market_list_salls').remove();
 	    		$('.content').append(dom);
 	    	});
 	    	var html='<div class="office_market_list_salls">'
 				 	+'<a href="javascript:;" class="tzsc_spfb"><img src="img/add_03.png" /><span>发布商品</span></a></div>'
 				 	+'<div class="office_market_list_sall"><ul>';
 	    	var html1='';
 			$.ajaxSettings.async=false;
 			$.getJSON('/WDDXSERVER/bsdt/tzsc_wdsplb.action?userid='+user_id+'&ticket='+ticket+'&pageSize=3&pageNum=1',
 				  {
 					function_id:function_id,
 					mmlx:_mmlx
 				  },
 				  function(data){
 					  if(!(data["content"].message.items==0||data["content"].message.items==null)){
 				 		 $.each(data["content"].message.items,function(i,r){
 				 			html1+='<li class="'+r["spid"]+'" id="'+r["flid"]+'" spms="'+r["spms"]+'" splx="'+r["flmc"]+'" spmc="'+r["spmc"]+'" spzt="'+r["spzt"]+'">'
 				 			+'<a href="javascript:;" ><div><img src="'+r["fjdz"]+'" /></div><span '+r["spjg"]+'>￥'+r["spjg"]+'</span><p>'+r["spmc"]+'</p></a></li>';
 				 		 });
 					  }
 				  });
 				html+=html1+'</ul></div>'
 				+'<div class="pagechange"><ul>'
 				+'<li class="nextpage"><a href="javascript:;">下一页></a></li>'
 				+'<li class="index"><a href="javascript:;">首页</a></li>'
 				+'<li class="previouspage"><a href="javascript:;"><上一页</a></li>'
 				+'</ul></div>';
 				$('.office_lists').empty().append(html);
 			//商品发布
 			tzscSpfb();	
 			//商品下架
 			tzscSpxj();
 			fyWdsplb(_mmlx);
 		});	 
 		
 }
  function fyWdsplb(_mmlx){
 	 var pageNum=1;
 	 $('.pagechange ul li').unbind('click').click(function(){
 		 var className=$(this).attr("class");
 			 if(className=='nextpage'){
 				 pageNum+=1;
 				 pageWdsplb(_mmlx,pageNum);
 			 }else if(className=='previouspage'){
 				 pageNum-=1;
 				 if(pageNum==0){ pageNum=1;}
 				 pageWdsplb(_mmlx,pageNum);
 			 }else{
 				 pageNum=1;
 				 pageWdsplb(_mmlx,pageNum);
 			 }
 });
 }
 function pageWdsplb(_mmlx,pageNum){
 	 var html='<div class="office_fun_info"><ul>';
 		$.ajaxSettings.async=false;
 		$.getJSON('/WDDXSERVER/bsdt/tzsc_wdsplb.action?userid='+user_id+'&ticket='+ticket+'&pageSize=3',
 			  {
 				function_id:function_id,
 				mmlx:_mmlx,
 		 		pageNum:pageNum
 			  },
 			  function(data){
 	 		 $.each(data["content"].message.items,function(i,r){
 					html+='<li class="'+r["spid"]+'" id="'+r["flid"]+'">'
 					+'<a href="javascript:;"><div><img src="'+r["fjdz"]+'" /></div><span>￥'+r["spjg"]+'</span><p>'+r["spmc"]+'</p></a></li>';
 	 		 });
 			  });
 		html+='</ul></div>'
 			+'</div>';
 		$('.office_market_list_sall').empty().append(html);
 		//商品发布
 		tzscSpfb();	
 		//商品下架
 		tzscSpxj();
 }
  
  //商品列表

  function tzscLb(){
 	 $('.office_market_function ul li').click(function(e){
 		 var px='k';
 		 var _flbh=$(this).attr('class');
// 		 var splx=$(this).children().text();
 		  var doms = $('.content').children().clone(true);
 	    	$('.content').children().remove();
 	    	$('a.back-reveal-modal').show(0);
 	    	$('a.back-reveal-modal').unbind('click').click(function(){
 	    		$(this).hide(0);
 	    		$('div.office_phone').remove();
 	    		$('.content').append(doms);
 	    	});
 	   	 var html='<div class="office_phone"><div class="office_fun_title"><ul>'
 			 	+'<li class="a_active"><a href="javascript:;" class="k">最新</a></li>'
 			 	+'<li><a href="javascript:;" class="j">价格由高到低</a></li>'
 			 	+'<li><a href="javascript:;" class="s">价格由低到高</a></li></ul></div>'
 			 	+'<div class="office_fun_info"><ul>';
 		$.ajaxSettings.async=false;
 		$.getJSON('/WDDXSERVER/bsdt/tzsc_splb.action?userid='+user_id+'&ticket='+ticket+'&pageSize=3&pageNum=1',
 			  {
 				function_id:function_id,
 		 		flbh:_flbh,
 		 		px:px
 			  },
 			  function(data){
 	 		 $.each(data["content"].message.items,function(i,r){
 					html+='<li class="'+r["spid"]+'" id="'+r["flid"]+'">'
 					+'<a href="javascript:;"><div><img src="'+r["fjdz"]+'" /></div><span>￥'+r["spjg"]+'</span><p>'+r["spmc"]+'</p></a></li>';
 	 		 });
 			  });
 		html+='</ul></div>'
 			+'<div class="pagechange"><ul>'
 			+'<li class="nextpage"><a href="javascript:;">下一页></a></li>'
 			+'<li class="index"><a href="javascript:;">首页</a></li>'
 			+'<li class="previouspage"><a href="javascript:;"><上一页</a></li>'
 			+'</ul></div>'
 			+'</div>';
 		$('.content').append(html);
 		tzscSpxq(doms);
 		//商品排序
 		tzscSppx(_flbh,doms);
 		fySplb(_flbh,doms,px);
 	 });
  }
  function fySplb(_flbh,doms,px){
 	 var pageNum=1;
 	 $('.pagechange ul li').unbind('click').click(function(){
 		 var className=$(this).attr("class");
 			 if(className=='nextpage'){
 				 pageNum+=1;
 				 pageSplb(_flbh,pageNum,doms,px);
 			 }else if(className=='previouspage'){
 				 pageNum-=1;
 				 if(pageNum==0){pageNum=1;}
 				 pageSplb(_flbh,pageNum,doms,px);
 			 }else{
 				 pageNum=1;
 				 pageSplb(_flbh,pageNum,doms,px);
 			 }
  });
  }
  function pageSplb(_flbh,pageNum,doms,px){
    	 var html='<div class="office_fun_info"><ul>';
 	$.ajaxSettings.async=false;
 	$.getJSON('/WDDXSERVER/bsdt/tzsc_splb.action?userid='+user_id+'&ticket='+ticket+'&pageSize=3',
 		  {
 			function_id:function_id,
 	 		flbh:_flbh,
 	 		pageNum:pageNum,
 	 		px:px
 		  },
 		  function(data){
  		 $.each(data["content"].message.items,function(i,r){
 				html+='<li class="'+r["spid"]+'" id="'+r["flid"]+'">'
 				+'<a href="javascript:;"><div><img src="'+r["fjdz"]+'" /></div><span>￥'+r["spjg"]+'</span><p>'+r["spmc"]+'</p></a></li>';
  		 });
// 			  }
 		  });
 	html+='</ul></div>'
 		+'</div>';
 	$('.office_fun_info').empty().append(html);
 	tzscSpxq(doms);
  }
  
  //商品详情
  function tzscSpxq(index_doms){
 	 $('div.office_phone div.office_fun_title ul li a').click(function(){
 		 $(this).parent().siblings().removeClass("a_active");
 		 $(this).parent().addClass("a_active");	
 	 });
 	 $('.office_fun_info ul li').click(function(){
 		 var _flbh=$(this).attr('id');
 		 var _spid=$(this).attr('class');
 		 var doms = $('.content').children().clone(true);
     	 $('.content').children().remove();
     	 $('a.back-reveal-modal').show(0);
     	 $('a.back-reveal-modal').unbind('click').click(function(){
     		$('div.tzsc_shop_xq').remove();
     		$('.content').append(doms);
     		 $('a.back-reveal-modal').unbind('click').click(function(){
     	    		$(this).hide(0);
     	    		$('div.office_phone').remove();
     	    		$('.content').append(index_doms);
     	    		
     	    	 });
     	 });
     	 var html='<div class="tzsc_shop_xq"><div class="shop_message"><div class="shop_img">';
     	  $.ajaxSettings.async=false;
           $.getJSON('/WDDXSERVER/bsdt/tzsc_spxq.action?userid='+user_id+'&ticket='+ticket,
         		  {
         	  	  function_id:function_id,
         	      spid:_spid
     	    	 },
         		  function(data){
     	    		 $.each(data["content"].message.items,function(i,r){
     	   	    			html+='<img src="'+data["content"].message.items[i].fjdz+'"/>';
     	   	    		 });
 		    	    		 html+='</div>'
 		    	    			 +'<a href="javascript:;" class="spsc" id="'+data["content"].message.items[0].spzt+'"><img src="img/scdbb.png"/><span>收藏</span></a>'
 		    	    			 +'<a href="javascript:;"><span>'+data["content"].message.items[0].lxdh+'</span><img src="img/phone.png"/></a>'
 		    	    			 +'<p><label>商品描述：</label><span>'+data["content"].message.items[0].spms+'</span></p>'
 	    	    			 +'</div>'
 	    	    			 +'<div class="shop_info"><h5>'+data["content"].message.items[0].spmc+'</h5>'
 	    	    			 	+'<div class="shop_price"><a href="javascript:;" class="tzsc_jbsp">举报</a>'
 		    	    			+'<p><label>商品售价</label><span>￥'+data["content"].message.items[0].spjg+'</span></p>'
 		    	    			+'<p><label>商品类型</label><span>'+data["content"].message.items[0].flmc+'</span></p>'
 	    	    			 +'</div>'
 	    	    			 +'<p>给卖家留言：</p>'
 	    	    			 +'<div class="ly" contenteditable="true"></div>'
 	    	    			 +'<button class="sendmsg">发送</button>'
     	    			 +'</div></div>';
         		  });
           $('.content').append(html);
           //商品收藏
           tzscSpsc(_spid);
           //商品举报
           tzscJbsp(_flbh);
 	 });
  }
  
  //排序
  function tzscSppx(_flbh,doms){
 	 $('.office_fun_title ul li a').click(function(){
 		 var px=$(this).attr('class');
 		 var html='<div class="office_fun_info"><ul>';
 		$.ajaxSettings.async=false;
 		$.getJSON('/WDDXSERVER/bsdt/tzsc_splb.action?userid='+user_id+'&ticket='+ticket+'&pageSize=3&pageNum=1',
 			  {
 				function_id:function_id,
 		 		flbh:_flbh,
 		 		px:px
 			  },
 			  function(data){
 	 		 $.each(data["content"].message.items,function(i,r){
 					html+='<li class="'+r["spid"]+'" id="'+r["flid"]+'">'
 					+'<a href="javascript:;"><div><img src="'+r["fjdz"]+'" /></div><span>￥'+r["spjg"]+'</span><p>'+r["spmc"]+'</p></a></li>';
 	 		 });
 			  });
 		html+='</ul></div>';
 		$('.office_fun_info').empty().append(html);
 		tzscSpxq(doms);	
 		fySplb(_flbh,doms,px);
 	 });
  }
  //商品收藏
  function tzscSpsc(_spid){
 	 var num=0; 
 	 $('.spsc').click(function(e){ 
 		 var _spzt=$(this).attr('id');
 	 if(num++ %2 == 0){ 
 		$('.spsc span').text('已收藏');
 		$.ajaxSettings.async=false;
 		$.getJSON('/WDDXSERVER/bsdt/tzsc_Scsp.action?function_id=20150117&userid='+user_id+'&ticket='+ticket,
 			  {
 				spbh:_spid,
 				spzt:_spzt
 			  },
 			  function(data){}
 			  );
 	 }else{ 
 		 $('.spsc span').text('收藏');
 	 } 
 	 }); 
  }

  //商品收藏列表

  function tzscSclb(){
 	 $('.wdspsc').click(function(){
 		 var px='k';
 		 $('div.office_phone div.office_fun_title ul li a').click(function(){
 			 $(this).parent().siblings().removeClass("a_active");
 			 $(this).parent().addClass("a_active");	
 		 });
 		var doms= $('.content').children().clone(true);
 		 $('.content').children().remove();
 	    	$('a.back-reveal-modal').show(0);
 	    	$('a.back-reveal-modal').unbind('click').click(function(){
 	    		$(this).hide(0);
 	    		$('.office_fun_title').remove();
 	    		$('div.office_fun_info').remove();
 	    		$('div.pagechange').remove();
// 	    		$('.content').children().remove();
 	    		$('.content').append(doms);
 	    	});
 	 var html='<div class="office_phone"><div class="office_fun_title"><ul>'
 				 	+'<li class="a_active"><a href="javascript:;" class="k">最新</a></li>'
 				 	+'<li><a href="javascript:;" class="j">价格由高到低</a></li>'
 				 	+'<li><a href="javascript:;" class="s">价格由低到高</a></li></ul></div>'
 			+'<div class="office_fun_info">'
 		 	+'<ul>';
 	$.ajaxSettings.async=false;
 	$.getJSON('/WDDXSERVER/bsdt/tzsc_Sclb.action?userid='+user_id+'&ticket='+ticket+'&pageSize=3&nowpage=1',
 		  {
 		function_id:function_id,
 		px:px
 		  },
 		  function(data){
 		 $.each(data["content"].message.items,function(i,r){
 				html+='<li class="'+r["spid"]+'">'
 				+'<a href="javascript:;"><div><img src="'+r["fjdz"]+'" /></div><span>￥'+r["spjg"]+'</span><p>'+r["spmc"]+'</p></a></li>';
 		 });
 		  });
 	html+='</ul></div>'
 		+'<div class="pagechange"><ul>'
 		+'<li class="nextpage"><a href="javascript:;">下一页></a></li>'
 		+'<li class="index"><a href="javascript:;">首页</a></li>'
 		+'<li class="previouspage"><a href="javascript:;"><上一页</a></li>'
 		+'</ul></div>';
 	$('.content').append(html);	
 	tzscSpxqSc(doms);
 	//收藏页面商品排序
 	sclbPx(doms);
 	fySclb(doms,px);
 	 });
  }

  //商品收藏详情
  function tzscSpxqSc(index_doms){
 	 $('div.office_phone div.office_fun_title ul li a').click(function(){
 		 $(this).parent().siblings().removeClass("a_active");
 		 $(this).parent().addClass("a_active");	
 	 });
 	 $('.office_fun_info ul li').click(function(){
 		 var _spid=$(this).attr('class');
 		 var doms = $('.content').children().clone(true);
     	 $('.content').children().remove();
     	 $('a.back-reveal-modal').show(0);
     	 $('a.back-reveal-modal').unbind('click').click(function(){
     		$('div.tzsc_shop_xq').remove();
     		$('.content').append(doms);
     		 $('a.back-reveal-modal').unbind('click').click(function(){
     	    		$(this).hide(0);
     	    		$('div.office_phone').remove();
     	    		$('.content').append(index_doms);
     	    		
     	    	 });
     	 });
     	 var  html='<div class="tzsc_shop_xq"><div class="shop_message"><div class="shop_img">';
     	  $.ajaxSettings.async=false;
           $.getJSON('/WDDXSERVER/bsdt/tzsc_spxq.action?userid='+user_id+'&ticket='+ticket,
         		  {
         	  	  function_id:function_id,
         	      spid:_spid
     	    	 },
         		  function(data){
     	    		 $.each(data["content"].message.items,function(i,r){
  	   	    			html+='<img src="'+data["content"].message.items[i].fjdz+'"/>';
  	   	    		 });
 	    	    		html+='</div>'
 	    	    			 +'<a href="javascript:;" class="spsc" id="'+data["content"].message.items[0].spzt+'"><img src="img/scdbb.png"/><span>已收藏</span></a>'
 	    	    			 +'<a href="javascript:;"><span>'+data["content"].message.items[0].lxdh+'</span><img src="img/phone.png"/></a>'
 	    	    			 +'<p><label>商品描述：</label><span>'+data["content"].message.items[0].spms+'</span></p>'
     	    			 +'</div>'
     	    			 +'<div class="shop_info"><h5>'+data["content"].message.items[0].spmc+'</h5>'
     	    			 	+'<div class="shop_price"><a href="javascript:;" class="tzsc_jbsp">举报</a>'
 	    	    			+'<p><label>商品售价</label><span>￥'+data["content"].message.items[0].spjg+'</span></p>'
 	    	    			+'<p><label>商品类型</label><span>'+data["content"].message.items[0].flmc+'</span></p>'
     	    			 +'</div>'
     	    			 +'<p>给卖家留言：</p>'
     	    			 +'<div class="ly" contenteditable="true"></div>'
     	    			 +'<button class="sendmsg">发送</button>'
 	    			 +'</div></div>';
         		  });
           $('.content').append(html);
           //取消收藏
           tascQxsc(_spid);
           //商品举报
           tzscJbsp(_spid);
 	 });
  }
  
  
  function fySclb(doms,px){
 	 var pageNum=1;
 	 $('.pagechange ul li').unbind('click').click(function(){
 		 var className=$(this).attr("class");
 			 if(className=='nextpage'){
 				 pageNum+=1;
 				 pageSclb(pageNum,doms,px);
 			 }else if(className=='previouspage'){
 				 pageNum-=1;
 				 if(pageNum==0){pageNum=1;}
 				 pageSclb(pageNum,doms,px);
 			 }else{
 				 pageNum=1;
 				 pageSclb(pageNum,doms,px);
 			 }
  });
  }
  function pageSclb(pageNum,doms,px){
    	 var html='<div class="office_fun_info"><ul>';
 	$.ajaxSettings.async=false;
 	$.getJSON('/WDDXSERVER/bsdt/tzsc_Sclb.action?userid='+user_id+'&ticket='+ticket+'&pageSize=3',
 		  {
 			function_id:function_id,
 	 		nowpage:pageNum,
 	 		px:px
 		  },
 		  function(data){
  		 $.each(data["content"].message.items,function(i,r){
 				html+='<li class="'+r["spid"]+'" id="'+r["flid"]+'">'
 				+'<a href="javascript:;"><div><img src="'+r["fjdz"]+'" /></div><span>￥'+r["spjg"]+'</span><p>'+r["spmc"]+'</p></a></li>';
  		 });
 		  });
 	html+='</ul></div>'
 		+'</div>';
 	$('.office_fun_info').empty().append(html);
 	tzscSpxqSc(doms);
  }
 //商品排序
  function sclbPx(doms){
 	 $('.office_fun_title ul li a').click(function(){
 		 var px=$(this).attr('class');
 		 var html='<div class="office_fun_info"><ul>';
 		$.ajaxSettings.async=false;
 		$.getJSON('/WDDXSERVER/bsdt/tzsc_Sclb.action?userid='+user_id+'&ticket='+ticket+'&pageSize=3&nowpage=1',
 			  {
 				function_id:function_id,
 		 		px:px,
 			  },
 			  function(data){
 	 		 $.each(data["content"].message.items,function(i,r){
 					html+='<li class="'+r["spid"]+'">'
 					+'<a href="javascript:;"><div><img src="'+r["fjdz"]+'" /></div><span>￥'+r["spjg"]+'</span><p>'+r["spmc"]+'</p></a></li>';
 	 		 });
 			  });
 		html+='</ul></div>';
 		$('.office_fun_info').empty().append(html);
 		tzscSpxqSc(doms);	
 		fySclb(doms,px);
 	 });
 	 
  }
  
  //取消商品收藏
  function tascQxsc(_flbh){
 	 $('.spsc').click(function(){
 		 $('.spsc span').text('收藏');
 		 $.ajaxSettings.async=false;
 			$.getJSON('/WDDXSERVER/bsdt/tzsc_Qxsc.action?function_id=20150117&userid='+user_id+'&ticket='+ticket,
 				  {
 				spbh:_flbh
 				  },
 				  function(data){});
 	 });
  }
  
 //举报商品
  function tzscJbsp(_flbh){
 	 var _jbyy="no";
 	 $('.tzsc_jbsp').click(function(){
 		 $.ajaxSettings.async=false;
 			$.getJSON('/WDDXSERVER/bsdt/tzsc_Spjb.action?userid='+user_id+'&ticket='+ticket,
 				  {
 				   spbh:_flbh,
 				   jbrbh:user_id,
 				   function_id:function_id,
 				   jbyy:_jbyy
 				  },
 				  function(data){
 					  alert("已举报");
 				  });
 		 
 	 });
  }
  
  //商品发布
  function tzscSpfb(){
 	 $('.tzsc_spfb').click(function(){
 		 num=0;
 		 var doms= $('.content').children().clone(true);
 		 $('.content').children().remove();
 	    	$('a.back-reveal-modal').show(0);
 	    	$('a.back-reveal-modal').unbind('click').click(function(){
 	    		$(this).hide(0);
 	    		$('.office_tzsc_spfb').remove();
 	    		$('.content').append(doms);
 	    		num=0;
 	    	});
 		 
 		 var html='<div class="office_tzsc_spfb">'
 			 +'<p>商品名称</p><input type="text" placeholder="单行输入" class="spmc">'
 			 +'<p>商品类型</p><select class="splx">'
 				 +'<option value="1">手机</option>'
 				 +'<option value="2">摄像器材</option>'
 				 +'<option value="3">数码游戏</option>'
 				 +'<option value="4">电脑配件</option>'
 				 +'<option value="5">女装</option>'
 				 +'<option value="6">男装</option>'
 				 +'<option value="7">鞋包/配饰</option>'
 				 +'<option value="8">香水/美容</option>'
 				 +'<option value="9">书籍/影音</option>'
 				 +'<option value="10">食品/水果</option>'
 				 +'<option value="11">体育用品</option>'
 				 +'<option value="12">其他</option>'
 			 +'</select>'
 			 +'<p>商品状态</p><select class="spzt">'
 				 +'<option  value="1">正常</option>'
 				 +'<option  value="2">缺货</option>'
 				 +'<option  value="3">打折</option>'
 				 +'<option  value="4">热卖</option>'
 				 +'<option  value="5">推荐</option>'
 			 +'</select>'
 			 +'<p>联系价格</p><input type="text" placeholder="请输入商品价格（只允许数字）" class="spjg">'
 			 +'<p>联系电话</p><input type="text" placeholder="请输入联系电话（只允许数字）" class="lxdh" maxlength="11">'
 			 +'<p>商品描述</p><textarea  placeholder="请输入商品描述" class="spms"></textarea>'
 			 +'<p>照片</p>'
 			 +'<div class="imgs">'
 			 	+'<form class="upload" id="fileForm" method="post" action="/FS/loadpic/loadpicsform.action?" name="fileForm1" enctype="multipart/form-data" >'
 			 	+'<img src="img/addimg.png" id="xmTanImg" class="xmTanImg"/><p>添加照片</p>'
 			 	+'<input type="file" name="file" class="upload_img" id="tascUploadImg" onchange="xmTanUploadImg(this)"/>'
 			 +'</form></div>'
 	         +'<div id="xmTanDiv"></div>'
 	         +'<iframe name="uploadFrame" id="uploadFrame" style="display:none;"></iframe>'
 			 +'<input class="submit" type="button" value="提交">'
 			 +'</div>';
 	$('.content').empty().append(html);
 	upLoadImg();
 	 });
  }
  
 //判断浏览器是否支持FileReader接口
 if (typeof FileReader == 'undefined') {
     document.getElementById("xmTanDiv").InnerHTML = "<h1>当前浏览器不支持FileReader接口</h1>";
     //使选择控件不可操作
     document.getElementById("tascUploadImg").setAttribute("disabled", "disabled");
 }

 //选择图片，马上预览
 var num=0;
 //var upl=$('.upload').clone(true);
 function xmTanUploadImg(obj) {
 	num++;
 	var upl=$('.upload').clone(true);
     var file = obj.files[0];               // console.log(obj);console.log(file);
     console.log("file.size = " + file.size);  //file.size 单位为byte
     var reader = new FileReader();
     //读取文件过程方法
     reader.onloadstart = function (e) {
         console.log("开始读取....");
     };
     reader.onprogress = function (e) {
         console.log("正在读取中....");
     };
     reader.onabort = function (e) {
         console.log("中断读取....");
     };
     reader.onerror = function (e) {
         console.log("读取异常....");
     };
     reader.onload = function (e) {
         console.log("成功读取....");
 	    var img = document.getElementById("xmTanImg");
 	    img.src = e.target.result;
 	    //或者 img.src = this.result;  //e.target == this
 	            };
     reader.readAsDataURL(file);
     if(num<6){
     	 $('.imgs').prepend(upl);
     	 $('.imgs p:first').remove();
     }else{
     	alert("一次最多只能上传5张");
     }    
     $('.imgs form:first').css({"padding-top":"0","height":"81px","margin-right":"1em"});
     $('.imgs form img:first').css({"width":"100%"});
     $('.imgs form img:first').css({"height":"100%"});
     $('.imgs form:first').attr({"id":"fileForm"+num});
     $('.imgs form:first').attr({"class":"upload"+num});
     $('.imgs form input:first').attr({"class":"upload_img"+num});
     $('.imgs form input:first').attr({"disabled":"true"});
     var upload=$('.upload_img').val();
     $('.imgs form input:first').attr({"value":upload});
     subimtBtn();
     
 }

 //form上传图片回调
 var _fjlb=[];
 function subimtBtn() {  
 	var jsondata='';
 	 $("#fileForm").ajaxForm({   
 		 	dataType: "json",
// 		 	url:'http://desktop-mgjr52l:8080/loadpic/loadpicsform.action?',    
 	        type:'post', 
 	        success:function(data){
 	        	jsondata=data["list"][0].OriginalImage;
// 	        	console.log(data["list"][0].OriginalImage);
 	        }
 	    }).submit();
 	 _fjlb.push(jsondata);
 } 
  //跳蚤市场-发布商品信息
 function upLoadImg(){
 	 $('.submit').click(function(){
 		 addData();
 	 });
 }

 function addData(){
 	 var _spmc=$('.spmc').val();
 	 var _splx=$('.splx option:selected').val();
 	 var _spjg=$('.spjg').val();
 	 var _spms=$('.spms').val();
 	 var _spzt=$('.spzt option:selected').val();
 	 var _lxdh=$('.lxdh').val();
 	 var _mmlx=2;
 	 $.ajax({
 		 url:'/WDDXSERVER/bsdt/tzsc_Fbsp.action?userid='+user_id+'&ticket='+ticket,
 	    	type:'get',
 	    	data:{
 	    		function_id:function_id,
 	    		spmc:_spmc,
 	    		splx:_splx,
 	    		spjg:_spjg,
 	    		spms:_spms,
 	    		spzt:_spzt,
 	    		lxdh:_lxdh,
 	    		mmlx:_mmlx,
 	    		spfbr:user_id,
 	    		pics:_fjlb.join()    //数组转换成字符串
 	    	},
 	    	dataType:'json',
 	    	success:function(data){}
 	 });
 }

 //我的买卖列表详情
 function tzscSpxj(){
 	 $('.office_market_list_sall ul li').click(function(){
// 		 var _flbh=$(this).attr('id');
 		 var _spid=$(this).attr('class');
 		 var spms='';
 		 var spmc='';
// 		 var splx=$(this).attr('splx');
 		 var _spzt=$(this).attr('spzt');
 		 var src=$(this).children().children().children().attr('src');
 		 var doms = $('.content').children().clone(true);
 	   	 $('.content').children().remove();
 	   	 $('a.back-reveal-modal').show(0);
 	   	 $('a.back-reveal-modal').unbind('click').click(function(){
 	   		$(this).hide(0);
    		 $('div.tzsc_shop_xj').remove();
    		$('.content').append(doms);
    	 });
    	 var html='<div class="tzsc_shop_xj"><div class="shop_message"><div class="shop_img">';
    	  $.ajaxSettings.async=false;
          $.getJSON('/WDDXSERVER/bsdt/tzsc_spxq.action?function_id=20150117&userid='+user_id+'&ticket='+ticket,
        		  {
        	      spid:_spid
    	    	 },
        		  function(data){
    	    		 $.each(data["content"].message.items,function(i,r){
    	    			html+='<img src="'+data["content"].message.items[i].fjdz+'"/>';
    	    		 });
    	    		 spms=data["content"].message.items[0].spms;
    	    		 spmc=data["content"].message.items[0].spmc;
    	    		_spzt=data["content"].message.items[0].spshzt;
    	    		   html+='</div>'
     	    			 +'<a href="javascript:;" class="spsc"><img src="img/scdbb.png"/><span>收藏</span></a>'
     	    			 +'<a href="javascript:;"><span class="lxdz">'+data["content"].message.items[0].lxdh+'</span><img src="img/phone.png"/></a>'
     	    			 +'<p><label>商品描述：</label><span>'+spms+'</span></p>'
 	    			 +'</div>'
 	    			 +'<div class="shop_xj"><h5>'+data["content"].message.items[0].spmc+'</h5>'
 	    			 	+'<div class="shop_price">'
     	    			+'<p><label>商品售价</label><span id="spjg" class="'+data["content"].message.items[0].spjg+'">￥'+data["content"].message.items[0].spjg+'</span></p>'
     	    			+'<p><label>商品类型</label><span>'+data["content"].message.items[0].flmc+'</span></p>'
 	    			 +'</div>'
 	    			 +'<button class="spxj">下架</button>'
 	    			 +'<button class="spbj">编辑</button>'
    	    			 +'</div></div>';
        		  });
          $('.content').append(html);
          //商品编辑
          tzscSpbj(doms,_spzt,_spid,spmc,spms,src);
          //商品下架
          tzscSpxjXq(_spid,_spzt);
 	 });
 }

 //商品下架
 function tzscSpxjXq(_spid,_spzt){
 	$('.spxj').click(function(){
 		$.ajaxSettings.async=false;
 		$.getJSON('/WDDXSERVER/bsdt/tzsc_Spxj.action?userid='+user_id+'&ticket='+ticket,
 				{
 			   	spbh:_spid,
 			   	function_id:function_id,
 				spzt:_spzt
 				},
 				function(data){});
 	});
 }

 //修改商品
 function tzscSpbj(dom,_spzt,_spid,spmc,spms,src){
 	$('.spbj').click(function(){
 		var lxdz=$('.shop_message a span.lxdz').text();
 		var spjg=$('#spjg').attr('class');
 		 var doms = $('.content').children().clone(true);
     	 $('.content').children().remove();
     	 $('a.back-reveal-modal').show(0);
     	 $('a.back-reveal-modal').unbind('click').click(function(){
     		$('div.office_tzsc_spfb').remove();
     		$('.content').append(doms);
     		 $('a.back-reveal-modal').unbind('click').click(function(){
     	    		$(this).hide(0);
     	    		$('div.tzsc_shop_xj').remove();
     	    		$('.content').append(dom);
     	    		
     	    	 });
     	 });
     	 var html='';
 			 html='<div class="office_tzsc_spfb">'
 					 +'<p>商品名称</p><input type="text" class="spmc" value="'+spmc+'">'
 					 +'<p>商品类型</p><select>'
 						 +'<option class="splx" value="1">手机</option>'
 						 +'<option value="2">摄像器材</option>'
 						 +'<option value="3">数码游戏</option>'
 						 +'<option value="4">电脑配件</option>'
 						 +'<option value="5">女装</option>'
 						 +'<option value="6">男装</option>'
 						 +'<option value="7">鞋包/配饰</option>'
 						 +'<option value="8">香水/美容</option>'
 						 +'<option value="9">书籍/影音</option>'
 						 +'<option value="10">食品/水果</option>'
 						 +'<option value="11">体育用品</option>'
 						 +'<option value="12">其他</option>'
 					 +'</select>'
 					 +'<p>商品状态</p><select>'
 						 +'<option class="spzt" value="1">正常</option>'
 						 +'<option  value="2">缺货</option>'
 						 +'<option  value="3">打折</option>'
 						 +'<option  value="4">热卖</option>'
 						 +'<option  value="5">推荐</option>'
 					 +'</select>'
 					 +'<p>商品价格</p><input type="text" class="spjg" value="'+spjg+'">'
 					 +'<p>联系电话</p><input type="text" placeholder="请输入联系电话（只允许数字）" value="'+lxdz+'" maxlength="11">'
 					 +'<p>商品描述</p><textarea  placeholder="请输入商品描述" class="spms">'+spms+'</textarea>'
 					 +'<p>照片</p>'
 					 +'<div class="imgs" id="addimgs">'
 					 	+'<form class="upload" id="fileForm" method="post" action="/FS/loadpic/loadpicsform.action?" name="fileForm1" enctype="multipart/form-data" >'
 						+'<img src="'+src+'" id="xmTanImg" class="xmTanImg"/><p>添加照片</p>'
 					 	+'<input type="file" name="file" class="upload_img" id="tascUploadImg" onchange="xmTanUploadImg(this)"/>'
 					 +'</form></div>'
 			         +'<div id="xmTanDiv"></div>'
 			         +'<iframe name="uploadFrame" id="uploadFrame" style="display:none;"></iframe>'
 					 +'<input class="submit" type="button" value="提交">'
 				 +'</div>';
 		
 		 $('.content').append(html);
 		 upLoadImgs(_spid);
 	});
 }
 //跳蚤市场-发布商品信息
 function upLoadImgs(_spid){
 	 $('.submit').click(function(){
 		 addDataXg(_spid);
 	 });
 }

 function addDataXg(_spid){
 	 var _spmc=$('.spmc').val();
 	 var _splx=$('.splx').val();
 	 var _spjg=$('.spjg').val();
 	 var _spms=$('.spms').val();
 	 var _spzt=$('.spzt').val();
// 	 var _spzt=$('.spzt option:selected').val();
 	 $.ajax({
 		 url:'/WDDXSERVER/bsdt/tzsc_Xgsp.action?userid='+user_id+'&ticket='+ticket,
 	    	type:'get',
 	    	data:{
 	    		function_id:function_id,
 	    		spmc:_spmc,
 	    		splx:_splx,
 	    		spjg:_spjg,
 	    		spms:_spms,
 	    		spzt:_spzt,
 	    		spbh:_spid,
 	    		pics:_fjlb.join()
 	    	},
 	    	dataType:'json',
 	    	success:function(data){}
 	 });
 }

 //跳蚤市场-搜索商品
 function tzscDzsplb(){
 	 $('.Dzsplb').click(function(){        
 		var _spmc=$('.spmcSs').val();
 		var px='k';
 		var doms = $('.content').children().clone(true);
     	$('.content').children().remove();
     	$('a.back-reveal-modal').show(0);
     	$('a.back-reveal-modal').unbind('click').click(function(){
     		$(this).hide(0);
     		$('div.office_phone').remove();
     		$('.content').append(doms);
     	});
 		 var html='<div class="office_phone"><div class="office_fun_title"><ul>'
 			 	+'<li class="a_active"><a href="javascript:;" class="k">最新</a></li>'
 			 	+'<li><a href="javascript:;" class="j">价格由高到低</a></li>'
 			 	+'<li><a href="javascript:;" class="s">价格由低到高</a></li></ul></div>'
 			 	+'<div class="office_fun_info"><ul>';
 		$.ajaxSettings.async=false;
 		$.getJSON('/WDDXSERVER/bsdt/tzsc_Dzsplb.action?userid='+user_id+'&ticket='+ticket+'&pageSize=3&pagenow=1',
 			  {
 			function_id:function_id,
 			spmc:_spmc,
 			px:px
 			  },
 			  function(data){
 	 		 $.each(data["content"].message.items,function(i,r){
 					html+='<li class="'+r["spid"]+'">'
 					+'<a href="javascript:;"><div><img src="'+r["fjdz"]+'" /></div><span>￥'+r["spjg"]+'</span><p>'+r["spmc"]+'</p></a></li>';
 	 		 });
 			  });
 		html+='</ul></div>'
 			+'<div class="pagechange"><ul>'
 			+'<li class="nextpage"><a href="javascript:;">下一页></a></li>'
 			+'<li class="index"><a href="javascript:;">首页</a></li>'
 			+'<li class="previouspage"><a href="javascript:;"><上一页</a></li>'
 			+'</ul></div>'
 			+'</div>';
 		$('.content').append(html);
 		tzscSpxq(doms);
 		sslbPx(_spmc,doms);
 		fySslb(_spmc,doms,px);
 	 }); 
 }
 //搜索列表排序
 function sslbPx(_spmc,doms){
 	 $('.office_fun_title ul li a').click(function(){
 		 var px=$(this).attr('class');
 		 var html='<div class="office_fun_info"><ul>';
 		$.ajaxSettings.async=false;
 		$.getJSON('/WDDXSERVER/bsdt/tzsc_Dzsplb.action?userid='+user_id+'&ticket='+ticket+'&pageSize=3&pagenow=1',
 			  {
 				function_id:function_id,
 		 		px:px,
 		 		spmc:_spmc
 			  },
 			  function(data){
 	 		 $.each(data["content"].message.items,function(i,r){
 					html+='<li class="'+r["spid"]+'">'
 					+'<a href="javascript:;"><div><img src="'+r["fjdz"]+'" /></div><span>￥'+r["spjg"]+'</span><p>'+r["spmc"]+'</p></a></li>';
 	 		 });
 			  });
 		html+='</ul></div>';
 		$('.office_fun_info').empty().append(html);
 		tzscSpxq(doms);
 		fySslb(_spmc,doms,px);
 	 });
 }
 function fySslb(_spmc,doms,px){
 	 var pageNum=1;
 	 $('.pagechange ul li').unbind('click').click(function(){
 		 var className=$(this).attr("class");
 			 if(className=='nextpage'){
 				 pageNum+=1;
 				 pageSslb(_spmc,pageNum,doms,px);
 				 return;
 			 }else if(className=='previouspage'){
 				 pageNum-=1;
 				 if(pageNum==0){pageNum=1;}
 				 pageSslb(_spmc,pageNum,doms,px);
 			 }else{
 				 pageNum=1;
 				 pageSslb(_spmc,pageNum,doms,px);
 			 }
 });
 }
 function pageSslb(_spmc,pageNum,doms,px){
    	 var html='<div class="office_fun_info"><ul>';
 	$.ajaxSettings.async=false;
 	$.getJSON('/WDDXSERVER/bsdt/tzsc_Dzsplb.action?userid='+user_id+'&ticket='+ticket+'&pageSize=3',
 		  {
 			function_id:function_id,
 			pagenow:pageNum,
 	 		spmc:_spmc,
 	 		px:px
 		  },
 		  function(data){
  		 $.each(data["content"].message.items,function(i,r){
 				html+='<li class="'+r["spid"]+'" id="'+r["flid"]+'">'
 				+'<a href="javascript:;"><div><img src="'+r["fjdz"]+'" /></div><span>￥'+r["spjg"]+'</span><p>'+r["spmc"]+'</p></a></li>';
  		 });
// 			  }
 		  });
 	html+='</ul></div>'
 		+'</div>';
 	$('.office_fun_info').empty().append(html);
 	tzscSpxq(doms);
 }